In a programming language such as Java® (Java is a trademark of Sun Microsystems, Inc.) where packaging or modules are used as a way to organize code bases, the placement of source files within packages contributes to important effects in the type system of the language and the data structures of both compilers and code-aware integrated development environments (IDEs). Some programming languages (e.g., Java) also possess an intrinsic syntax for metadata known as “annotations”. Tools that process annotations and use them for analysis and code generation of artifacts can be integrated with both command line compilers and IDEs. In an incremental, real-time analysis system like an IDE, one of the most challenging questions is how to maintain the correctness of the type system and the incremental (minimal rebuild) properties that involve changes to packages and package contents.
The interaction of these two phenomenon are interesting and somewhat complex because of the nature in which they can interact: source files can refer to types that are produced by running annotation processors over the metadata in the original file; the “target” of such references will not exist until the metadata processing has completed. There is also the possibility of multiple “rounds”: a generated source file may itself have annotations, which require further applications of annotation processors which may generate even more source files and so forth. Some, none, or all of these various source files from various “levels” of metadata-driven code generation may be in the same package, and may refer to types defined in other such files.
A naïve implementation would recompile individual source files too many times; in fact, it might not even have linear behavior in the number of source files. To add a final level of complexity, this may occur in a system which is multi-threaded, in which case different threads may be engaged in various states of compiling different files and processing annotations (or generating code from them).